<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>

<h3 style="padding-left: 20px;padding-top: 10px">
	<?=$info['title']?>——栏目
	<?php if($source_type == 1){?>
	<a href="./index.php?m=information&c=information&a=index" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
	<?php }elseif($source_type == 2){?>
	<a href="./index.php?m=video&c=manage&a=init" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
	<?php }elseif($source_type == 3){?>
	<a href="?m=picture&c=picture&a=index" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
	<?php }?>
</h3>

<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		<?php if($source_type == 1){?>
		<a href="./index.php?m=information&c=information&a=show&id=<?=$id?>"><em>详情</em></a>
		<?php }elseif($source_type == 2){?>
		<a href="./index.php?m=video&c=manage&a=show&id=<?=$id?>"><em>详情</em></a>
		<?php }elseif($source_type == 3){?>
		<a href="./index.php?m=picture&c=picture&a=show&id=<?=$id?>"><em>详情</em></a>
		<?php }?>
		<!-- <span>|</span>
		<a href="./index.php?m=information&c=contest&a=index&id=<?=$id?>&source_type=<?=$source_type?>"><em>赛事</em></a> -->
		<span>|</span>
		<a href="./index.php?m=information&c=talent&a=index&id=<?=$id?>&source_type=<?=$source_type?>"><em>人才</em></a>
		<span>|</span>
		<a href="./index.php?m=information&c=category&a=index&id=<?=$id?>&source_type=<?=$source_type?>" class="on"><em>栏目</em></a>

	</div>
</div>

<div class="pad-lr-10">

	<form name="searchform" action="" method="get">
		<input type="hidden" value="information" name="m">
		<input type="hidden" value="category" name="c">
		<input type="hidden" value="index" name="a">
		<input type="hidden" value="<?=$id?>" name="id">
		<input type="hidden" value="<?=$source_type?>" name="source_type">
		<input type="hidden" value="<?php echo $_SEEEION['pc_hash'];?>" name="pc_hash">

		<table width="100%" cellspacing="0" class="search-form">
			<tbody>
			<tr>
				<td>
					<!-- <button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showAdd()" ><em>添加栏目</em></button> -->
					<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showSelect()" ><em>选择栏目</em></button>
					<span style="clear: both"></span>
					<script>
						function showAdd(){
							window.top.art.dialog({
									id: 'add',
									iframe: '?m=information&c=category&a=add&id=<?=$id?>',
									title: '添加赛事',
									width: '900',
									height: '500',
									lock: true
								},
								function() {
									var d = window.top.art.dialog({
										id: 'add'
									}).data.iframe;
									var form = d.document.getElementById('dosubmit');
									form.click();
									return false;
								},
								function() {
									window.top.art.dialog({
										id: 'add'
									}).close()
								});
						}
						function  showSelect(){
							window.top.art.dialog({
									id: 'select',
									iframe: '?m=information&c=category&a=bindCategory&id=<?=$id?>&source_type=<?=$source_type?>',
									title: '选择赛事',
									width: '900',
									height: '500',
									lock: true
								},
								function() {
									var d = window.top.art.dialog({
										id: 'select'
									}).data.iframe;
									var relation = d.document.getElementById('relation');

									$.ajax({
										type:"get",
										url:"?m=information&c=category&a=bindCategoryAjax&id=<?=$id?>&relation="+relation.value+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>&source_type=<?=$source_type?>",
										dataType: "json",
										success:function(data){
											if(data['status']){
												window.top.art.dialog({
													id: 'select'
												}).close()
												window.location.reload();
											}else{
												alert(data['msg']);
												return false;
											}
										}
									})
									return false;
								},
								function() {
									window.top.art.dialog({
										id: 'select'
									}).close()
								});
						}
					</script>

					<div class="explain-col">
						<?php echo L('catname')?>：
						<input name="catname" type="text" value="<?php if(isset($_GET['catname'])) {echo $_GET['catname'];}?>"
							   class="input-text" />
						<input type="submit" name="search"  class="button" value="<?php echo L('search')?>" />
					</div>


				</td>
			</tr>
			</tbody>
		</table>
	</form>

	<form name="myform" action="?m=information&c=category&a=delete" method="post"
		onsubmit="return confirm('<?php echo L('confirm')?>')">
		<div class="table-list">
			<table width="100%" cellspacing="0">
				<thead>
					<tr>
						<th align="left" width="20"><input type="checkbox" value=""
							id="check_box" onclick="selectall('id[]');"></th>
						<th width="57"><?php echo L('listorder');?></th>
						<th align="left">ID</th>
						<th align="left"><?php echo L('catname')?></th>
						<th align="left"><?php echo L('category_type')?></th>
						<th align="left"><?php echo L('modelname')?></th>

						<th align="left"><?php echo L('operations_manage')?></th>
					</tr>
				</thead>
				<tbody>
<?php
if (!empty($contestinfo)){
foreach ($contestinfo as $k => $v) {
    ?>
    <tr>
		<td align="left"><input type="checkbox"
			value="<?php echo $v['cid']?>" name="id[]"></td>
		<td align='center'><input name='listorders[<?php echo $v['cid'];?>]' type='text' size='3' value='<?php echo $v['sort'];?>' class='input-text-c'></td>
		<td align="left"><?php echo $v['catid']?></td>
		<td align="left"><?php echo $v['catname']?></td>
		<td align="left"><?php echo $types[$v['type']]?></td>
		<td align="left"><?php echo $models[$v['modelid']]['name']?></td>

		<td align="left">


			<a href="?m=information&c=category&a=delete&id=<?php echo $v['cid']?>"
			onClick="return confirm('<?php echo L('confirm')?>')">[<?php echo L('deletebind')?>]</a>
			<?php if($v['is_top'] == 0){?>
			<a href="?m=information&c=category&a=isTop&id=<?php echo $v['cid']?>&is_top=1"
			style="color:green">[<?php echo L('is_top')?>]</a>
			<?php }else{?>
			<a href="?m=information&c=category&a=isTop&id=<?php echo $v['cid']?>&is_top=0"
			style="color:red">[<?php echo L('no_top')?>]</a>
			<?php }?>
		</td>
	</tr>
<?php
}
} else {
	echo "<tr><td colspan='7' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
}
?>
</tbody>
			</table>

			<div class="btn">
				<label for="check_box">
					<a href="#"
					onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('select_all')?></a>/<a
					href="#"
					onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a></label>
					<input type="button" class="button" value="<?php echo L('listorder');?>" onclick="myform.action='?m=information&c=category&a=listorder&dosubmit=1&steps=<?php echo $steps;?>';myform.submit();"/>
				<input type="submit" class="button" name="dosubmit"
					value="<?php echo L('deletebind')?>" />
			</div>

			<div id="pages"><?php echo $pages?></div>
		</div>
	</form>
</div>

</body>
</html>